package LIR;

public class LirTranslation 
{
	public enum Type
	{
		VariableLoc,
		ArrayLoc,
		ExternalLoc,
		Register,
		Literal,
	}
	
	private String  _translation;
	private String 	_targetRegister;
	private Type    _type;
	
	public LirTranslation(String translation, String targetRegister, Type type) 
	{
		_translation = translation;
		_targetRegister = targetRegister;
		_type = type;
	}
	
	public LirTranslation(String translation, String targetRegister) 
	{
		this(translation, targetRegister, Type.Register);
	}
	
	public LirTranslation(String translation, int targetRegister) 
	{
		this(translation, "R"+targetRegister);
	}
	
	void setTargetRegister(String _targetRegister) 
	{
		this._targetRegister = _targetRegister;
	}
	
	String getTargetRegister() 
	{
		return _targetRegister;
	}
	
	void setTranslation(String _translation) 
	{
		this._translation = _translation;
	}
	
	public String getTranslation() 
	{
		return _translation;
	}
	
	public String getMove()
	{
        switch(_type)
        {
        	case VariableLoc:
	        case Register:
	        case Literal: 
	        	return "Move ";
	        case ExternalLoc: 
	        	return "MoveField ";
	        case ArrayLoc: 
	        	return "MoveArray ";
	        default:
	                throw new RuntimeException("Unknown lir-type");
        }
	}
	public Type getType()
	{
		return _type;
	}
}